package com.icecloud.cloud.upms.action;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.icecloud.cloud.upms.common.utils.IpUtils;
import com.icecloud.cloud.upms.common.utils.RestfulResponseBody;
import com.icecloud.cloud.upms.entity.CoreUser;
import com.icecloud.cloud.upms.service.CoreUserService;

/**
 * 测试核心用户
 * 
 * @author penghaozhong
 *
 */
@RestController
public class CoreUserController {

	@Autowired
	private CoreUserService coreUserService;
	
	/**
	 * 新增一个用户
	 * 
	 * @param departmentId
	 * @return
	 */
	@RequestMapping(value = "/coreuser", method = RequestMethod.POST)
	public ResponseEntity<RestfulResponseBody> save(@RequestBody CoreUser coreUser,HttpServletRequest request) {
		RestfulResponseBody body = new RestfulResponseBody();
		coreUser.setRegisterIp(IpUtils.getIpAddr(request));
		coreUserService.save(coreUser);
		body.setReason("成功");
		body.setResultFlag(1);

		return new ResponseEntity<RestfulResponseBody>(body, HttpStatus.OK);
	}
	
}
